<?php
/**
 * 	JFormField Reset
 *
 * @package		SyntaxHighlighter
 * @copyright		Copyright (C) 2007 - 2011 Yoshiki Kozaki(www.joomler.net) All rights reserved.
 * @license		GNU General Public License version 2 or later
 */

defined('JPATH_BASE') or die;

class JFormFieldReset extends JFormField
{
	/**
	* Element name
	*
	* @access	protected
	* @var		string
	*/
	protected $type = 'Reset';

	protected function getInput()
	{
		JHTML::_('behavior.framework');

		$js = "window.addEvent('domready', function(){%s});";

		$msg = JText::_('PLG_CONTENT_SHL_AFTERRESET_MSG');

		$temp = "document.id('resetbtn').addEvent('click', function(){ $$('.pane-sliders input', '.pane-sliders select').each(function(e){
			switch(e.get('type')){
				case 'select-one': e.options.selectedIndex = 0; break;
				case 'select-multiple': for(var i = 0; i < e.options.length;i++) e.options[i].selected = false; break;
				case 'text': e.set('value', ''); break;
				case 'radio': if(e.get('value') != 'default') e.checked = false; else e.checked = true;
			}
		}); alert('$msg');});";

		JFactory::getDocument()->addScriptDeclaration(sprintf($js, $temp));
		return '<input type="button" id="resetbtn" class="inputbox" value="'. JText::_('PLG_CONTENT_SHL_RESET'). '" />';
	}
}
